package com.itheima.mapper;

import com.itheima.dto.EmpLoginDto;
import com.itheima.dto.EmpQueryDto;
import com.itheima.pojo.Emp;
import com.itheima.vo.EmpVo;
import com.itheima.vo.SexVo;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface EmpMapper {

    List<EmpVo> query(EmpQueryDto dto);

    void insert(Emp emp);

    @Select("select * from emp where id=#{id} ")
    Emp getById(Integer id);

    void update(Emp emp);

    @Delete("delete from emp where id=#{id}")
    void delete(Integer integer);

    @Select("select * from emp")
    List<Emp> selectAll();

    @Select("select if(gender=1,'男','女' ) as name ,count(gender) as value from emp group by gender")
    List<SexVo> sex();

    @Select("select case when job=1 then '班主任' when job=2 then '讲师'when job=3 then '学工主管'when job=4 then '教研主管' when job=5 then '咨询师' else '未知' end as name ,count(job) as value from emp group by job")
    List<SexVo> Job();


    @Select("select * from emp where username=#{username}")
    Emp login(EmpLoginDto empLoginDto);

    @Delete("delete from emp where dept_id=#{id}")
    void deleteByDeptId(Integer id);
}
